Report For Section: IdxDataRecs(Item).Section Sunday, July 10,1994 4:23p 142F6.THD 3D-Painting CDK MS BASIC+ CIS:MSBASI0 CIS:MSBASI CDK MS BASIC+ 3D-Painting Steve McClaire (SL) 71075,1775 Mats Claesson 70630,1337 @lMats, Are you returning 0 in response to WM_PAINT to indicate you handled the message? It sounds like you might be letting the WM_PAINT fall through to default processing after you've done your painting, and the default processing is painting over what you've done. Steve McClaire Microsoft Developer Support @lP Brett Foster 70444,135 Mats Claesson 70630,1337 Mats, It sounds like you should either call VBSuperControlProc or VBDefControlProc when you get WM_PAINT, and after the function returns, draw your 3d highlights. Does that make sense? BrettP Mats Claesson 70630,1337 Brett Foster 70444,135 OK, I will try . Thank you for your suggestions.. Regards Mat 1432A.THD Get a menu control Tag CDK MS BASIC+ CIS:MSBASI< CIS:MSBASI*C CDK MS BASIC+ Get a menu control Tag Brett Foster 70444,135 Andrew Westacott 100023,702 Andrew, If you have the control handle (HCTL) of a menu "control", then getting its Tag property is no different than getting the tag of any other control. That is, you must step through the PROPINFO pointers in its MODEL structure until you find PPROPINFO_STD_TAG. You need to watch out for the fact that the PROPINFO pointers, like all pointers in the MODEL structure, are NEAR offsets into the segment containing the MODEL; so you have to manufacture FAR pointers manually. Also, standard properties are stored as phony pointers >PPROPINFO_STD_LAST; so you can't dereference them. On the other hand, if you only have an HMENU then there is no straightforward way to determine the HCTL. You could use VBGetControl to enumerate all the menu controls on the form and compare their captions; but there could be duplicates. The HMENU is stored in the control structure, but it's not documented and may not work in other versions of VB. Bret 1438A.THD VBX Destroying CDK MS BASIC+ CIS:MSBASI3 CIS:MSBASI CDK MS BASIC+ VBX Destroying Nick Slater 100045,271 all Could anybody please advise how to prevent VB programmer from adding additional instances of control at design time. i.e Have written a vbx but need to restrict use to 150 instances of the control, so when designer attempts to place an additional instance onto a form nothing hapens. I have tried returning zero in the wm_nccreate handler and attempted to let the control be created but posted it a wm_destroy in the vbm_created handler, neither work. Any advice would be appreciated. Many thanks.V Steve McClaire (SL) 71075,1775 Nick Slater 100045,271 @lNick, Unfortunately the current custom control model doesn't provide any clean way to abort the creation of a control. The two main ways to do this are: 1) Return -1 from WM_CREATE. This will notify VB that the control could not be created, unfortunately VB assumes that this failure was due to a lack of memory or system resources, so it generates an "Out of memory" error. If you use this method you might want to bring up a messagebox before returning -1 and notify the user that they are about to get an out of memory error that can be ignored. 2) If you post a WM_KEYDOWN for the delete key to the control in WM_CREATE, you can 'fake' the control into thinking its been deleted by the user (just as if the VB user had hit delete). Steve McClaire Microsoft Developer Support @lN Brett Foster 70444,135 Nick Slater 100045,271 Nick, The only way to prevent a control from getting created is to return -1 in response to WM_CREATE. Unfortunately this also produces an "Out of memory" error message. Some folks have had success with posting a message to the VB design environment equivalent to the Edit.Delete menu command. But of course that won't work if the control is created by a Load statement at runtime. Bret 143A3.THD Author to Update VB book CDK MS BASIC+ CIS:MSBASI= CIS:MSBASI CDK MS BASIC+ Author to Update VB book Sunthar Visuvalinga 73443,2030 All SAMS Publishing is looking for a qualified author to update an existing book on Visual Basic 4.0 for Windows Programming. The prospective author must be on the Visual Basic 4.0 beta program and preferably on teh Chicago beta as well. Some background in developing OLE Custom Controls would be a plus. If you are interested please call Sunthar ASAP at (317) 581-4690. Or leave a message for me. We need to start work immediately! Thanks Suntha 143F2.THD Update to MsgSpy VBX CDK MS BASIC+ CIS:MSBASI9 CIS:MSBASI CDK MS BASIC+ Update to MsgSpy VBX Tony Scott 100265,2172 All In response to user feedback, version 2.1 of the Message Spy VBX has now been released allowing both pre-processing and post-processing of all messages, as well as the ability to completely modify messages, message parameters and message return values. All registered users of the control will receive an automatic upgrade to the new version. MS BASIC+ forum; CDK library [16] Tony Scott Anton Software Limited (The Message Spy VBX is used to "spy" on Windows and VB messages received by VB controls and forms. It fires an event when a message is received, passing the message details, and the ACTUAL control or form the message was intended for! All messages can be spied upon, or just a single specified message. Both pre-processing and post-processing of messages are supported. Message numbers need never be used, as message names are acceptable in all places. Highly optimised for maximum performance.) 14438.THD DC passed in on WM_PAINT CDK MS BASIC+ CIS:MSBASI= CIS:MSBASI8D CDK MS BASIC+ DC passed in on WM_PAINT Dave Thielen 74104,467 all Hi; In a VBX WM_PAINT is documented (ie the samples show this) as passing a DC in wParam if wParam is != 0. However, I have found at times that wParam has values like 1 and 7. I just received the following from the WINSDK forum. > Since an hDC is just a local handle in GDI's data segment, it follows that 1 (or 7) is _not_ > a reasonable value for an hDC. Although there is no IsHdc() function, you might be able > to use the IsGDIObject() function. This function is documented as returning a BOOL (so > caveat emptor), but actually returns a WORD in Windows 3.1 indicating the type of GDI object: So what gives??? thanks - daveN Brett Foster 70444,135 Dave Thielen 74104,467 Dave, I have never encountered bogus DC values in WM_PAINT. Can you reproduce this using one of the samples, like CIRC3? Does it happen with subclassed Windows controls, non-subclassed controls, or both? BrettN Dave Thielen 74104,467 Brett Foster 70444,135 I wrote a control that's a 3D status bar (I wrote my own because I wanted text, not a #% in the middle) - its pretty simple & straightforward. I think I derived it from CIRC1... - daveN Brett Foster 70444,135 Dave Thielen 74104,467 Dave, One way I could imagine you getting bogus wparam values for WM_PAINT is if you had a case statement immediately preceding "case WM_PAINT" which didn't always return or break. Then sometimes it might fall through to the WM_PAINT case and get confused. If you can reproduce the problem with a simple control like one of the samples I would be willing to look at it. Just email the zipped source code. Bret 14458.THD String in Property Box CDK MS BASIC+ CIS:MSBASI; CIS:MSBASIXD CDK MS BASIC+ String in Property Box Andrew Chalk 70253,1452 sysop I have a question about something that I expect everyone knows except me and the two people that I have asked. I have written a custom property that is an HSZ. At design time the user can edit the string in the property box. Suppose that the string that the user desires to enter is "ac" followed by a carriage return (In C, the string would be denoted as "ac\r"). I have found no way for the user to enter the carriage return in the property settings box (they have to do it in code). I tried "at + Chr(13)" but that is interpreted as a string literal. I also tried entering the carriage return from the numberic keypad. That also does not work. Am I missing something? Regards. Brett Foster 70444,135 Andrew Chalk 70253,1452 Andrew, The only way you can let a user embed newlines in a string property is to provide a popup dialog. This would be displayed when the user pressed the ellipsis button to the right of the edit control. There are a number of steps you must take to implement this. First of all, respond to VBM_INITPROPPUP for your string property by creating a dummy window and returning its handle. Second, when the dummy window receives WM_SHOWWINDOW with wParam <> 0, post a message to yourself; and when you get that message, call VBDialogBoxParam to display the popup. The documentation isn't too clear on this, and it is needlessly complicated; but there is an example in CIRC3. Also, if you want the user to still be able to edit directly in the properties window without using your popup, set the PF_fEditable flag. BrettO Andrew Chalk 70253,1452 Brett Foster 70444,135 Many thanks. I recommend you make the feature available in VB4. Regards. Brett Foster 70444,135 Andrew Chalk 70253,1452 Andrew, >> I recommend you make the feature available in VB4. If it was up to me, I might consider it; but I'm not with MS. BrettO Andrew Chalk 70253,1452 Brett Foster 70444,135 Oops! I presumed that you were, as you are so prolific in this forum. In that case, I will recommend to Microsoft that they make you an MVP (again). Regards. Steve McClaire (SL) 71075,1775 Andrew Chalk 70253,1452 @lAndrew, Your not missing anything - there is no way to put a carriage return into a string property via the property window. If you want to allow this, you might consider responding to the VBM_INITPROPPOPUP message for this property, and bringing up a custom property setting dialog box with a multi-line edit control. This way you could allow the user to put whatever text you want into the property since your not limited by the std property window. Steve McClaire Microsoft Developer Support @lW Andrew Chalk 70253,1452 Steve McClaire (SL) 71075,1775 Many thanks. Simon Dismore 100022,2425 Andrew Chalk 70253,1452 Andrew: You already have answers from Brett and Steve, so I expect you are now busily building your popup/dialog. I just wanted to remind you: if you use the default processing to set the string, the 256th byte may get nulled (see the VB3 VBM_SETPROPERTY comments). Sorry if you knew anyway! Andrew Chalk 70253,1452 Simon Dismore 100022,2425 Thanks. I got the sad-but-true news. Regards. 14471.THD Save Text Prop CDK MS BASIC+ CIS:MSBASI3 CIS:MSBASIqD CDK MS BASIC+ Save Text Prop Alan Jones 70740,3207 All I am having a problem using VBM_SAVETEXTPROPERTY to save string data to a form saved in text mode. I create a HSZ using VBCreateHsz, but the assignment *(LPSTR)lp = hsz // page 220 ProBook1 gives a compiler error. This is because you are assigning a char * to a char. I can create an equivalent effect but the program crashes on a save. If I use code as in the following: lp = (LONG)hsz I get a the property, but the string is "". Could anyone offer some advice. Alan Jones Brett Foster 70444,135 Alan Jones 70740,3207 Alan, I've never actually tried this, but I believe that the assignment should be: *(HSZ FAR *)lp = hsz; Hope that helps... Bret 144FD.THD CDK/SDK Help!!!!! CDK MS BASIC+ CIS:MSBASI6 CIS:MSBASI CDK MS BASIC+ CDK/SDK Help!!!!! Ken Lanteigne 71107,307 All I'm modifying the code of Crescent Software's PDQComm VBX, but for some reason, I can't set a custom property I created from Visual Basic. When I set the property (of type string) with a value... like "8180", I get a bunch of garbage from the VBX's pointer to that string. I'm using MSVC++ 1.5, and VB 3.0... below is some of my source code... The property (StrCriteria1) has the PF_fGetMsg and PF_fSetMsg flags set. This function is called upon receipt of the VBM_SETPROPERTY message being sent to the VBX Control Procedure. It's passed the hCtl, hWnd, wProperty, and lParam passed to the control proc. by Visual Basic. <> and I look for my custom property: <lpStrCriteria1, (LPSTR)lParam);...>> ..But this is what I see in the MSVC++ Watch Window for lParam: +(LPSTR)lParam = 0x221F:0x0094 "h\x04p\x04\x80\x04\x86\x04$\x04,\x044\x04L\x04d\x04|\x04|\x05l" Any Ideas???? Brett Foster 70444,135 Ken Lanteigne 71107,307 Ken, You didn't say whether your string property is a DT_HSZ or a DT_HLSTR. In the former case, your code should work; but in the latter case it would not. That's because the string data is passed as a far pointer to an HLSTR rather than a simple LPSTR. Bret 1451A.THD Transparent Controls CDK MS BASIC+ CIS:MSBASI9 CIS:MSBASI CDK MS BASIC+ Transparent Controls Dan Thompson 70242,2001 ALL To All, I am new to writing VBX's and this may be somewhat ambitious. I am trying to write a VBX which I call a Box. It does the following. It is a transparent window, which can be moved and resized. For moving I am using Windows Message 0x231 and 0x232 which I think are undocumented. When it has focus it has a WS_THICK border, otherwise not. I will use this control as a child to a picture box. The user will be able to move and size the control in order to define "interesting" locations on the picture. I will display up to 8 of these boxes at a time. It has two states, which can best be described as red and green. VB makes the decision as to the Red/Green state of the box. The border of the window should display the color state of the box. I guess I'm looking for a quick answer, as I've been struggling with this for almost 3 weeks and have very little to show for it. 1) Can I make a VBX transparent? I've trying to set WS_EX_TRANSPARENT in the WM_NCCREATE handler, and trying to set background color to 0xff000000. Doesn't work. 2) Can a control be a window? I'm trying to set style in the CREATESTRUCT to WS_VISIBLE|WS_CHILD|WS_BORDER|WS_THICK... I never see the window when running. 3) Can a control have it's own cursor? When the cursor is over this control I would like to display IDC_CROSS. SetCursor doesn't seem to work here. 4) Can I make the control respond to Messages 0x231 and 0x232? This requires WS_NCHITTEST, WS_NCPAINT, WS_ERASEBKGND to do things as well. I started with the CIRC2 shell and started modifying it, but I'm pretty lost right now. I have added a bit of code and at least it doesn't crash. HELP! HELP!O Andreas Mey 100111,305 Dan Thompson 70242,2001 Hi Dan, dunno much about writing VBX, but: did you try a standard VB rectangle control (light weight control)? It s a control, it can easily be moved, you can change the border thickness, it s transparent. Cheers, RalfO Brett Foster 70444,135 Dan Thompson 70242,2001 Dan, 1) You can make a transparent VBX. In your WM_NCCREATE handler you need code like this: dwExStyle = GetWindowLong(hwnd, GWL_EXSTYLE); dwExStyle |= WS_EX_TRANSPARENT; SetWindowLong(hwnd, GWL_EXSTYLE, dwExStyle); There is some trickiness in getting the window and its parent to paint properly. 2) Most controls are windows. The only ones that aren't have the MODEL_fGraphical flag set. Setting styles in the CREATESTRUCT is usually not sufficient; you often have to SetWindowLong as shown above. But if the styles are always the same, you might as well set them in your MODEL structure. 3) A control can have its own cursor. This can either be a class cursor if you're subclassing a Windows control, or it can be a custom cursor set on the fly. This is done in response to WM_SETCURSOR and/or WM_MOUSEMOVE depending on your needs. 4) I have no idea what your undocumented messages 0x231 and 0x232 are for. If you're going to paint your border using different colors, then you will have to handle WM_NCPAINT yourself and not pass it on to VBDefControlProc. BrettO Dan Thompson 70242,2001 Brett Foster 70444,135 Thank you for your reply. I am an idiot. After re-reading the CDK manual I got everything to work including my 0x231 and 0x232 messages. This stuff is really pretty simple. The only thing still bothering me is the transparent thing. If I remember correctly I was setting the WS_EX_TRANSPARENT the way you suggested, but I'll check again. Also there was another reply re using a standard VB rectangle, and I may try that. Of course the problem with my WM_NCPAINT message was that I was painting it AND passing it to VBDefControlProc instead of just returning 0. I panic'd. I'd been trying to do this using BC4.0, and the early version would not let me build a VBX, apparently the BC4.02 service update will let you build VBX's. I went back to BC3.1 and I was trying to do all of this in OWL, not having a solid background in manly windows programming. But I think I'm on the right track now 14547.THD HCTL As argument CDK MS BASIC+ CIS:MSBASI5 CIS:MSBASIGE CDK MS BASIC+ HCTL As argument Torsten Zimmermann 100325,3114 all How can call an VBX Event with a control as argument? i.e. the standard Drag events do this. I tried to declare this as a long argument and "C as Control" in the EVENTINFO - but this doesn't work. Thanks, TorstenV Brett Foster 70444,135 Torsten Zimmermann 100325,3114 Torsten, You can't have HCTL event arguments. The ones used by the Drag events are special and have some kind of drag-specific structure involved. However, you can make HCTL properties. These are created using the undocumented data type value of 0x40. If you want an HCTL property which refers to a form then you must use 0x3f instead. BrettV Tony Scott 100265,2172 Torsten Zimmermann 100325,3114 Hi Torsten, As Brett says, you can have controls (and forms) as properties, but not event parameters. We had a similar problem, and I think we found a satisfactory solution taking the property route. Check out our Message Spy VBX (in msgspy.zip) to say how we used it. Regards, Tony Scott Anton Software Limited 14580.THD DT_OBJECT Problem CDK MS BASIC+ CIS:MSBASI6 CIS:MSBASI CDK MS BASIC+ DT_OBJECT Problem William Daniels 74277,2262 all All - I'm trying to use the DT_OBJECT property in a VBX, but I'm having trouble getting past the compile stage. It seems that both vbapi.h and the OLE includes define VARIANT types, and they conflict big-time. When I posted in the MFC section on this topic, Brett mentioned that he may have seen a KB article on this VARIANT conflict, but I couldn't find it. Does anyone know how to get around this problem, or can someone point me in the direction of the KB article? Thanks, Keith McFarlane AT&TR Brett Foster 70444,135 William Daniels 74277,2262 Keith, I looked on MSDN #7 and couldn't find that article. I could have sworn that an MS rep mentioned it but maybe not. In any case, I think you will have to just separate the OLE code from the VBX code and pass the IDispatch between them as a long or something. BrettO Jim Mack 76630,2012 William Daniels 74277,2262 Keith - A Variant is a structure containing a union, and occupies a total of 16 bytes. The format underwent several changes during development and even in the VB2 beta, so I'm not surprised there's conflicting info. The first two bytes are an int, the Type of the variant. The next 8 bytes are a union with int, long, float, double The next 4 bytes are reserved for a HLSTR, when the Variant is a string The final 2 bytes are unused (padding) -- Jim 14590.THD Subclassing data control CDK MS BASIC+ CIS:MSBASI= CIS:MSBASI CDK MS BASIC+ Subclassing data control Andreas Mey 100111,305 all Hi everyone! m trying to subclass a VB data control from within my VBX. A code sample looks like this: PCTLPROC oldDataCntlProc; LONG FAR PASCAL MyCntlProc(HCTL hctl, HWND hwnd, int msg, int wp, LONG lp) { // do some stuff... // at the end call original data control procedure return (*oldDataCntlProc)(hctl, hwnd, msg, wp, lp); } void BeginSubclassing(HCTL datacntl) { LPMODEL model; model = VBGetControlModel(datacntl); oldDataCntlProc = model->pctlproc; // get orig. data control proc model->pctlproc = MyCntlProc; // start subclassing } Despite all my sweat and tears I can t get it to work. As soon as BeginSubclassing() has done its thing, the data control causes a crash when it has to process any event. What s wrong???? Please help. Thanks a lot in advance. Ral 14640.THD setvariant error CDK MS BASIC+ CIS:MSBASI5 CIS:MSBASI@F CDK MS BASIC+ setvariant error Jerry Gassie 74067,2001 sysop My vb app always bombs when I call an export that I try to set the passed variant to... the code is something like this... int FAR PASCAL _export TestRoutine(LPVAR); { HLSTR hlstr; char dtitle[] = "A Test"; int slen; slen = strlen(dtitle); hlstr = VBCreateHlstr(dtitle,slen); rtn = VBSetVariantValue(lpvTitle,VT_STRING,(LPVOID)&hlstr); VBDestroyHlstr(hlstr); return 0; } Can you tell me why vb is crashing? Its crashing on VBSetVariantValue... Thanks. 14643.THD Upload (Sysop Message) CDK MS BASIC+ CIS:MSBASI; CIS:MSBASICF CDK MS BASIC+ Upload (Sysop Message) Tony Scott 100265,2172 sysop We had a few "gremlins" creep into our uploads on Saturday (July 9th). Therefore, please ignore the msgspy.zip file uploaded then, and use only the one uploaded on Sunday (July 10th). Thanks in advance 14646.THD Upload (Sysop Message) CDK MS BASIC+ CIS:MSBASI; CIS:MSBASIFF CDK MS BASIC+ Upload (Sysop Message) Tony Scott 100265,2172 sysop We had a few "gremlins" creep into our uploads on Saturday (July 9th). Therefore, please ignore the msgspy.zip file uploaded then, and use only the one uploaded on Sunday (July 10th). Thanks in advance 1464D.THD Subclassing data control CDK MS BASIC+ CIS:MSBASI= CIS:MSBASIMF CDK MS BASIC+ Subclassing data control Andreas Mey 100111,305 all Hi everybody! Lately I tried subclassing a data control from within my latest VBX. Unfortunately to no avail. Always crashed the app completely. What did I do wrong??? Following is a small sample from my C source: PCTLPROC oldDataCntlProc; LONG FAR PASCAL _export MyDataCntlProc(HCTL hctl, HWND hwnd, int msg, int wp, long lp) { // do some stuff... // call original data control procedure return (*oldDataCntlProc)(hctl, hwnd, msg, wp, lp); } void BeginSubclassing(HCTL datacntl) { LPMODEL model; model = VBGetControlModel(datacntl); oldDataCntlProc = model->pctlproc; model->pctlproc = MyDataCntlProc; } After calling BeginSubclassing() the next (VB?) event to be processed by the data control crashes the app. Please help! Thanks in advance for any hint. Ral